from django.db import models

class Admin(models.Model):
    """管理员"""
    username = models.CharField(verbose_name="用户名", max_length=32)
    password = models.CharField(verbose_name="密码", max_length=64)

    def __str__(self):
        return self.username

class Iot01(models.Model):
    """物联网数据"""
    Temp = models.DecimalField(verbose_name="温度", max_digits=10, decimal_places=2, default=0)
    Hum = models.DecimalField(verbose_name="湿度", max_digits=10, decimal_places=2, default=0)
    MAC = models.CharField(verbose_name="MAC地址",max_length=32,default='1')


class Iot02(models.Model):
    """物联网数据"""
    CO = models.DecimalField(verbose_name="CO浓度", max_digits=10, decimal_places=2, default=0)
    CO2 = models.DecimalField(verbose_name="CO2浓度", max_digits=10, decimal_places=2, default=0)
    SO2 = models.DecimalField(verbose_name="SO2浓度", max_digits=10, decimal_places=2, default=0)
    NO2 = models.DecimalField(verbose_name="NO2浓度", max_digits=10, decimal_places=2, default=0)

class Iot3(models.Model):
    # PM传感器
    PM10 = models.DecimalField(verbose_name="PM", max_digits=10, decimal_places=2, default=0)
    PM25 = models.DecimalField(verbose_name="PM", max_digits=10, decimal_places=2, default=0)
    MAC = models.CharField(verbose_name="MAC地址",max_length=32,default='3')



class Equipment(models.Model):
    """设备列表"""
    MAC = models.CharField(verbose_name="MAC地址",max_length=32)
    title = models.CharField(verbose_name="名称", max_length=32)
    detail = models.TextField(verbose_name="详细信息")

    status_choice = {
        (1, "在线"),
        (2, "离线")
    }

    status = models.SmallIntegerField(verbose_name="状态", choices=status_choice, default=2)




